<template>
  <div id="message">
    <c-title :hide="false" :text="'消息'"></c-title>
    <div class="main" v-for="item in list" :key="item.id" @click="link(item)">
      <div class="avatar">
        <van-image width="3.5rem" height="3.5rem" round :src="item.avatar_image" />
        <span class="name">{{ item.name }}</span>
      </div>
      <div class="all" @click="link">
        全部消息&nbsp;>
      </div>
    </div>
  </div>
</template>

<script>
import { scrollMixin } from "utils/mixin";
import { Image } from "vant";
export default {
  mixins: [scrollMixin],
  data() {
    return {
      id: "",
      list: [],
      last_page: 1,
      current_page: 1,
      isLoadMore: true
    };
  },
  activated() {
    this.isLoadMore = true;
    this.id = this.$route.params.id;
    this.getData();
  },
  methods: {
    getMoreData() {
      this.isLoadMore = false;
      if (this.current_page >= this.last_page) {
        return false;
      } else {
        $http.post("plugin.lawyer-platform.frontend.controllers.message.getList", json).then(res => {
          this.isLoadMore = true;
          if (res.result == 1) {
            this.list = this.list.concat(res.data.list.data);
            this.current_page = res.data.list.current_page;
            this.last_page = res.data.list.last_page;
          }
        });
      }
    },
    getData() {
      $http.post("plugin.lawyer-platform.frontend.controllers.message.getLawyerList", { id: this.id }).then(res => {
        if (res.result) {
          this.last_page = res.data.list.last_page;
          this.list = res.data.list.data;
        } else {
          this.$toast(res.msg);
        }
      });
    },
    link(data) {
      this.$router.push(this.fun.getUrl("lawyerChart", {}, { l_id: data.id, message_type: 3 }));
    }
  },
  components: {
    VanImage: Image
  }
};
</script>

<style lang="scss" scoped>
.all {
  color: rgba(99, 99, 99, 100);
}

.name {
  margin-left: 0.5rem;
}

#message {
  background-color: #fff;
}

.avatar {
  display: flex;
  align-items: center;
}

.main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid rgba(241, 241, 241, 100);
}
</style>
